﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using YunHan.BuShi123.Model;
using YunHan.BuShi123.DAL;
using System.Data;
using System.Data.SqlClient;

namespace YunHan.BuShi123.BLL.Base
{
	/// <summary>
	/// Admin_Model的业务处理类
	/// </summary>
	public class Admin_Base_BLL
	{
		/// <summary>
		/// 添加Admin_Model
		/// </summary>
		/// <param name="admin">Model</param>
		/// <returns>最新编号</returns>
		public static int Add(Admin_Model admin)
		{
			return Admin_DAL.Add(admin);
		}
        
        /// <summary>
		/// 添加Admin_Model
		/// </summary>
		/// <param name="admin">Model</param>
		/// <returns>最新编号</returns>
		public static int Add(Admin_Model admin, SqlTransaction trans)
		{
			return Admin_DAL.Add(admin, trans);
		}
        
        /// <summary>
		/// 批量添加Admin
		/// </summary>
        /// <param name="ModelList"></param>
        /// <param name="BatchSize">每一批次的行数，每一批次结束时，将将批次的发送到服务器</param>
		/// <returns>最新编号</returns>
        public static void BatchAdd(List<Admin_Model> ModelList, int BatchSize)
        {
            Admin_DAL.BatchAdd(ModelList, BatchSize);
        }
        
        /// <summary>
		/// 批量添加Admin
		/// </summary>
        /// <param name="dt"></param>
        /// <param name="BatchSize">每一批次的行数，每一批次结束时，将将批次的发送到服务器</param>
		/// <returns>最新编号</returns>
        public static void BatchAdd(DataTable dt, int BatchSize)
        {
            Admin_DAL.BatchAdd(dt, BatchSize);
        }
			
		/// <summary>
        /// 更新一条数据
        /// </summary>
        /// <remarks>
        ///  e.g.:  
        ///  int result = Update("Name = @Name", "ID = @ID", new SqlParameter[]{new SqlParameter("@ID", 24), new SqlParameter("@Name", "test")});
        /// </remarks>
        /// <param name="updateSql">更新内容(不含SET)</param>
        /// <param name="whereSql">更新条件（不含WHERE）</param>
        /// <param name="parms">更新参数</param>
        /// <returns></returns>
        public static int Update(SqlTransaction trans, string updateSql, string whereSql, params SqlParameter[] parms)
        {
            return Admin_DAL.Update(trans, updateSql, whereSql, parms);
        }
        
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <remarks>
        ///  e.g.:  
        ///  int result = Update("Name = @Name", "ID = @ID", new SqlParameter[]{new SqlParameter("@ID", 24), new SqlParameter("@Name", "test")});
        /// </remarks>
        /// <param name="updateSql">更新内容(不含SET)</param>
        /// <param name="whereSql">更新条件（不含WHERE）</param>
        /// <param name="parms">更新参数</param>
        /// <returns></returns>
        public static int Update(string updateSql, string whereSql, params SqlParameter[] parms)
        {
            return Admin_DAL.Update(updateSql, whereSql, parms);
        }
		
		/// <summary>
        /// 更新一条数据
        /// </summary>
        /// <remarks>
        ///  e.g.:  
        ///  int result = Update("Name = @Name", "ID = @ID", Model);
        /// </remarks>
        /// <param name="updateSql">更新内容(不含SET)</param>
        /// <param name="whereSql">更新条件（不含WHERE）</param>
        /// <param name="admin">更新参数</param>
        /// <returns></returns>
        public static int Update(string updateSql, string whereSql, Admin_Model admin)
        {
            return Admin_DAL.Update(updateSql, whereSql, admin);
        }
        
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <remarks>
        ///  e.g.:  
        ///  int result = Update("Name = @Name", "ID = @ID", Model);
        /// </remarks>
        /// <param name="updateSql">更新内容(不含SET)</param>
        /// <param name="whereSql">更新条件（不含WHERE）</param>
        /// <param name="admin">更新参数</param>
        /// <returns></returns>
        public static int Update(SqlTransaction trans, string updateSql, string whereSql, Admin_Model admin)
        {
            return Admin_DAL.Update(trans, updateSql, whereSql, admin);
        }
		
        /// <summary>
        /// 根据自定义条件删除记录
        /// </summary>
        /// <remarks>
        ///  e.g.:  
        ///  int result = Delete("Name = @Name", new SqlParameter("@Name", "user0"));
        /// </remarks>
        /// <param name="whereSql">Condition</param>
        /// <returns>Delete Number</returns>
        public static int Delete(SqlTransaction trans, string whereSql, params SqlParameter[] parms)
        {
            return Admin_DAL.Delete(trans, whereSql, parms);
        }

		
       /// <summary>
        /// 根据主键删除记录记录
        /// </summary>
        /// <remarks>
        ///  e.g.:  
        ///  int result = Delete(iD);
        /// </remarks>
        /// <param name="iD">主键</param>
        /// <returns>Delete Number</returns>
        public static int DeleteByKeyField(SqlTransaction trans, int iD)
        {
            return Admin_DAL.DeleteByKeyField(trans, iD);
        }

        /// <summary>
        /// 根据主键查询
        /// </summary>
        /// <remarks>
        ///  e.g.:  
        ///  int result = GetModel("ID=@ID", new SqlParameter("@ID", "123"));
        /// </remarks>
        /// <param name="iD"></param>
        /// <returns>Subject_Base_DAL对象</returns>
        public static Admin_Model GetModel(string whereSql, params SqlParameter[] parms)
        {
            return Admin_DAL.GetModel(whereSql, parms);
        }

        /// <summary>
        /// 根据主键查询Subject_Base_DAL
        /// </summary>
        /// <param name="iD"></param>
        /// <returns>Subject_Base_DAL对象</returns>
        public static Admin_Model GetModelByKeyFiled(int iD)
        {
            return Admin_DAL.GetModelByKeyField(iD);
        }

        /// <summary>
        /// 获得列表
        /// </summary>
        /// <returns>Subject_Base_DAL集合</returns>
        public static List<Admin_Model> GetModelList(string selectSql, string whereSql, string orderSql, params SqlParameter[] parms)
        {
            return Admin_DAL.GetModelList(selectSql, whereSql, orderSql, parms);
        }
		
	/// <summary>
        /// 获得列表
        /// </summary>
        /// <param name="selectSql">查询字段，为空则查询所有字段</param>
        /// <param name="whereSql">查询条件</param>
        /// <param name="orderSql">排序字段</param>
        /// <param name="parms">参数</param>
        /// <returns></returns>
        public static DataTable GetList(string selectSql, string whereSql, string orderSql, params SqlParameter[] parms)
        {
            return Admin_DAL.GetList(selectSql, whereSql, orderSql, parms);
        }
		
		/// <summary>
        /// 分页返回符合条件的记录，可指定返回字段
        /// </summary>
        /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
        /// <param name="conditionSql">指定条件(不含Where)</param>
        /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
        /// <param name="orderBy">排序方式(不包含order by)</param>
        /// <param name="pageSize">分页大小--每页包含的记录数</param>
        /// <param name="pageIndex">页码--要获取第几页的记录</param>
        /// <param name="parms">执行SQL语句使用的参数</param>
        /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
        public static List<Admin_Model> GetModelListByPage(ref int totalCount, string conditionSql, string selectFields, string orderBy, int pageSize, int pageIndex, params SqlParameter[] parms)
		{
			return 	Admin_DAL.GetModelListByPage(ref totalCount, conditionSql, selectFields, orderBy, pageSize, pageIndex, parms);
		}
		
		/// <summary>
        /// 分页返回符合条件的记录，可指定返回字段
        /// </summary>
        /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
        /// <param name="conditionSql">指定条件(不含Where)</param>
        /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
        /// <param name="orderBy">排序方式(不包含order by)</param>
        /// <param name="pageSize">分页大小--每页包含的记录数</param>
        /// <param name="pageIndex">页码--要获取第几页的记录</param>
        /// <param name="parms">执行SQL语句使用的参数</param>
        /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
        public static DataTable GetListByPage(ref int totalCount, string condition, string selectFields, string orderBy, int pageSize, int pageIndex, params SqlParameter[] parms)
        {
            return Admin_DAL.GetListByPage(ref totalCount, condition, selectFields, orderBy, pageSize, pageIndex, parms);
        }
		

		
		/// <summary>
        /// 统计符合条件的记录数
        /// </summary>
        /// <param name="conditionSql">条件SQL(不含where)</param>
        /// <param name="parms">SQL参数</param>
        /// <returns></returns>
        public static int GetListCount(string conditionSql, params SqlParameter[] parms)
        {
            return Admin_DAL.GetListCount(conditionSql, parms);
        }
        
        /// <summary>
        /// 分页返回符合条件的记录，可指定返回字段
        /// 注意：仅MSSQL2005及以上可用
        /// </summary>
        /// <param name="joinSql">join语句，如inner Join B on GP_Agency.fdAgenID=B.fdAgenID</param>
        /// <param name="keyFiled">唯一主键，用于排序分页</param>
        /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
        /// <param name="conditionSql">指定条件(不含Where)</param>
        /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
        /// <param name="orderBy">排序方式(不包含order by)</param>
        /// <param name="pageSize">分页大小--每页包含的记录数</param>
        /// <param name="pageIndex">页码--要获取第几页的记录</param>
        /// <param name="parms">执行SQL语句使用的参数</param>
        /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
        public static DataTable GetListMSSQL2005_JOIN(string joinSql, string keyFiled, string conditionSql, string selectFields, string orderBy, ref int totalCount, int pageSize, int pageIndex, params SqlParameter[] parms)
        {
            return Admin_DAL.GetListMSSQL2005_JOIN(joinSql, keyFiled, conditionSql, selectFields, orderBy, ref totalCount, pageSize, pageIndex, parms);
        }

        /// <summary>
        /// 分页返回符合条件的记录，可指定返回字段
        /// 注意：仅MSSQL2005及以上可用
        /// </summary>
        /// <param name="joinSql">join语句，如inner Join B on GP_Agency.fdAgenID=B.fdAgenID</param>
        /// <param name="keyFiled">唯一主键，用于排序分页</param>
        /// <param name="totalCount">返回所有记录数,如果输入大于0,则不重新计算</param>
        /// <param name="conditionSql">指定条件(不含Where)</param>
        /// <param name="selectFields">要返回的字段，为空则返回所有字段</param>
        /// <param name="orderBy">排序方式(不包含order by)</param>
        /// <param name="pageSize">分页大小--每页包含的记录数</param>
        /// <param name="pageIndex">页码--要获取第几页的记录</param>
        /// <param name="parms">执行SQL语句使用的参数</param>
        /// <returns>按分页大小返回指定页码的记录的指定字段</returns>
        public static List<Admin_Model> GetModelListMSSQL2005_JOIN(string joinSql, string keyFiled, string conditionSql, string selectFields, string orderBy, ref int totalCount, int pageSize, int pageIndex, params SqlParameter[] parms)
        {
            return Admin_DAL.GetModelListMSSQL2005_JOIN(joinSql, keyFiled, conditionSql, selectFields, orderBy, ref totalCount, pageSize, pageIndex, parms);
        }
	}
}

